﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ArriviSoft.SlotMachine.Presenter;

namespace ArriviSoft.SlotMachine.View
{
    public partial class FormMain : Form, ISlotMachineView
    {
        private Image[] figures;
        private SlotMachinePresenter controller;

        public FormMain()
        {
            InitializeComponent();
            LoadFigures();
            this.pictureBox1.Image = figures[0];
            this.pictureBox2.Image = figures[0];
            this.pictureBox3.Image = figures[0];

            // Creates the Presenter
            this.controller = new SlotMachinePresenter((ISlotMachineView)this);
        }

        private void LoadFigures()
        {
            this.figures = new Image[] {
                global::ArriviSoft.SlotMachine.View.Properties.Resources.Cherry,
                global::ArriviSoft.SlotMachine.View.Properties.Resources.Apple,
                global::ArriviSoft.SlotMachine.View.Properties.Resources.Melon,
                global::ArriviSoft.SlotMachine.View.Properties.Resources.Bell,
                global::ArriviSoft.SlotMachine.View.Properties.Resources.Seven
            };

        }

        private void FormMain_Load(object sender, EventArgs e)
        {
            
            this.controller.InsertCoins(50);
            this.controller.InitializeView();

        }

        #region ISlotMachineView Members

        public void DisplayCoinsLeft(int coins)
        {
            this.labelMoney.Text = string.Format("{0} $", coins);
        }

        public void DisplayMessage(string message)
        {
            this.labelInfo.Text = message;
        }

        #endregion

        #region ISlotMachineView Members


        public void DisplayCombination(int[] combination)
        {
            this.pictureBox1.Image = this.figures[combination[0]];
            this.pictureBox2.Image = this.figures[combination[1]];
            this.pictureBox3.Image = this.figures[combination[2]];
        }

        #endregion

        private void buttonSpin_Click(object sender, EventArgs e)
        {
            this.controller.Play();
        }
    }
}
